﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NeuralNetworks.ActivationFunctions
{
    public class LogisticFunction : IActivationFunction
    {
        private double beta;

        public double Beta {get; set;}

        public LogisticFunction() { this.beta = 1.0; }
        public LogisticFunction(double beta) { this.beta = beta; }

        public double Compute(double x)
        {
            return (1.0 / (1.0 + Math.Pow(Math.E, -(beta * x))));
        }
        public double ComputeDifferential(double x)
        {
            double x1 = Compute(x);
            return x1 * (1.0 - x1) * beta;
        }

        public override string ToString()
        {
            return ActivationFunctionFactory.logisitic;
        }
    }
}
